/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	heyong 
 * 
 * <p>描   述  :   LargeRepairServiceImpl.java for com.pengtu.gsj.service.impl.zhgl    </p>
 * 
 * <p>最后修改 : $: 2017年8月23日-下午6:30:41 v 1.0.0	 heyong   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.zhgl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.zhgl.LargeRepairDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.zhgl.LargeRepair;
import com.pengtu.gsj.service.system.SystemManageService;
import com.pengtu.gsj.service.zhgl.LargeRepairService;

/**
 * 
 * LargeRepairServiceImpl
 * 
 * 2017年8月23日 下午6:30:41
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class LargeRepairServiceImpl implements LargeRepairService {
	@Autowired
	private LargeRepairDao largeRepairDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void saveLargeRepair(LargeRepair largeRepair){
		largeRepairDao.save(largeRepair);
	}
	
	@Override
	public Page<LargeRepair> findLargeRepair(Page<LargeRepair> page, final QueryFilter queryFilter){
		return largeRepairDao.findPage(page, queryFilter);
	}
	
	@Override
	public LargeRepair getLargeRepairById(String id){
		return largeRepairDao.get(id);
	}
	
	@Override
	public void  delateLargeRepair(LargeRepair largeRepair){
		if(largeRepair.getAttachments() != null){
			for(Attachment attachment : largeRepair.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		largeRepairDao.delete(largeRepair);
	}
	
	@Override
	public boolean checkTecYear(String year, String id){
		return largeRepairDao.checkProperty("testYear", year, id);
	}
}
